package thread;

public class SyncDemo3 {
    public static void main(String[] args) {
        Thread t1 = new Thread(){
            public void run() {
                Foo.dosome();//静态变量应类名.dosome()
            }
        };
        Thread t2 = new Thread(){
            public void run() {
                Foo.dosome();
            }
        };
        t1.start();
        t2.start();
    }
}
class Foo{
    //public static synchronized void dosome() {
    public static  void dosome() {
        synchronized (Foo.class) {
            try {
                Thread t = Thread.currentThread();
                System.out.println(t.getName() + "aaa");
                Thread.sleep(3000);
                System.out.println("bbb");
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
